<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$title}</h2>
    </div>
    <div class="with-padding">
        <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
        <div class="tab-wrap" style="margin-bottom: 5px">
            <ul class="nav nav-secondary group_nav">
                <volist name="group" id="vGroup">
                    <li class="<if condition="
                    $i eq 1">active</if>"><a href="javascript:">{$key}</a></li>
                </volist>
            </ul>
        </div>

        <form action="{$savePostUrl}" method="post" class="form-horizontal">
            <php>if($group){</php>
            <volist name="group" id="vGroup">
                <div class="group_list" style="<if condition='$i neq 1'>display: none;</if>">
                    <volist name="keyList" id="field">
                        <php>if(in_array($field['name'],$vGroup)){</php>
                        <include file="Builder/_key"/>
                        <php>}</php>

                    </volist>
                </div>
            </volist>

            <php>}else{</php>
            <volist name="keyList" id="field">
                <include file="Builder/_key"/>
            </volist>
            <php>}</php>
            <br/>

            <div class="form-item">
                <volist name="buttonList" id="button">
                    <button
                    {$button.attr}>{$button.title}</button>  &nbsp;
                </volist>
            </div>
        </form>
    </div>

</block>

<block name="script">
    <if condition="$importDatetimePicker">
        <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
        <php>if(C('COLOR_STYLE')=='blue_color') echo '
            <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">
            ';
        </php>
        <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
        <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
                charset="UTF-8"></script>

        <script>
            $('.time').datetimepicker({
                format: 'yyyy-mm-dd hh:ii',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });

            $('.time').change(function () {
                var fieldName = $(this).attr('data-field-name');
                var dateString = $(this).val();
                var date = new Date(dateString);
                var timestamp = date.getTime();
                $('[name=' + fieldName + ']').val(Math.floor(timestamp / 1000));
            });
        </script>
    </if>

    <if condition="$importCheckBox">
        <script>
            $(function () {
                function implode(x, list) {
                    var result = "";
                    for (var i = 0; i < list.length; i++) {
                        if (result == "") {
                            result += list[i];
                        } else {
                            result += ',' + list[i];
                        }
                    }
                    return result;
                }

                $('.oneplus-checkbox').change(function (e) {
                    var fieldName = $(this).attr('data-field-name');
                    var checked = $('.oneplus-checkbox[data-field-name=' + fieldName + ']:checked');
                    var result = [];
                    for (var i = 0; i < checked.length; i++) {
                        var checkbox = $(checked.get(i));
                        result.push(checkbox.attr('value'));
                    }
                    result = implode(',', result);
                    $('.oneplus-checkbox-hidden[data-field-name=' + fieldName + ']').val(result);
                });
            })
        </script>
    </if>

    <script type="text/javascript">
        $(function () {
            $('.group_nav li a').click(function () {
                $('.group_list').hide();
                $('.group_list').eq($(".group_nav li a").index(this)).show();
                $('.group_nav li').removeClass('active');
                $(this).parent().addClass('active');
            })
        })
        Think.setValue("type", {$info.type|default=0});
        Think.setValue("group", {$info.group|default=0});
        //导航高亮
        highlight_subnav('{:U('Config / index')}');
    </script>

</block>
